package com.shanzmoo.db.module.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shanzmoo.db.module.member.domain.query.PlfMemberCardConfigQuery;
import com.shanzmoo.db.module.member.domain.vo.PlfMemberCardConfigVO;
import com.shanzmoo.db.module.member.entity.MemberCardConfigEntity;
import com.shanzmoo.db.module.member.mapper.MemberCardConfigMapper;
import com.shanzmoo.db.module.member.service.IMemberCardConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 门店会员卡管理 服务实现类
 * </p>
 *
 * @author wangyudi
 * @since 2021-03-30
 */
@Service
public class MemberCardConfigServiceImpl extends ServiceImpl<MemberCardConfigMapper, MemberCardConfigEntity> implements IMemberCardConfigService {

    @Override
    public MemberCardConfigEntity getbyMerchantCode(String currentMerchantCode) {
        return getOne(
                new LambdaQueryWrapper<MemberCardConfigEntity>()
                        .eq(MemberCardConfigEntity::getMerchantCode,currentMerchantCode)
                        .eq(MemberCardConfigEntity::getDeleted,false)
                ,true
        );
    }

    @Override
    public void deleteByMerchantCode(String currentMerchantCode) {
        remove(
                new LambdaQueryWrapper<MemberCardConfigEntity>()
                .eq(MemberCardConfigEntity::getMerchantCode,currentMerchantCode)
        );
    }

    @Override
    public Page<PlfMemberCardConfigVO> queryPlfByRequest(PlfMemberCardConfigQuery query) {
        return baseMapper.queryPlfByRequest(query.page(),query);
    }
}
